<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	
	<script type="text/javascript">
	//  focus() 获得焦点 blur() 失去焦点
		window.onload=function (){
          document.getElementById("nickname").focus();
          var selYear=document.getElementById("selYear");
          var y=new Date().getFullYear();
          for(var i=y;i>=1897;i--){
               selYear.options[2016-i]=new Option(i+"年",i);
          }
          for(var i=1;i<=12;i++){
              selMonth.options[i-1]=new Option(i+"月",i);
          }
          for(var i=1;i<=31;i++){
          	selDay.options[i-1]=new Option(i+"日",i);
          }
		}
		function changeDay(){
			var selYear=document.getElementById("selYear").value;
			var selMonth=document.getElementById("selMonth");
			var selDay = document.getElementById("selDay");
			if(selMonth.value==1 || selMonth.value==3 || selMonth..value==5)
		}
		function alertnickname(){
			document.getElementById("divnickname").innerHTML="<font color='red'>请输入昵称</font>"
         }
		function checkNickName(){
              var nickname=document.getElementById("nickname").value;
          if(nickname==""){
          	 document.getElementById("divnickname").innerHTML="<font color='red'>用户名不能为空</font>"
          }else{
          	 document.getElementById("divnickname").innerHTML="<font color='green'>OK</font>"
          }
		}

		function alertNickPass(){
               document.getElementById("divnickpass").innerHTML="<font color='red'>长度为6-16位字符</font><br><font color='red'>不能包含空格</font><br><font color='red'>不能是9位以下纯数字</font><br>"
		}
		function checkNickPass(){
             var nickpass=document.getElementById("nickpass").value;
             var infor=""; 
             if(nickpass.length>6 && nickpass.length<16){
                	infor+="<font color='green'>长度为6-16位字符</font><br/>";
             }else{
                	infor+="<font color='red'>长度为6-16位字符</font><br/>";
             }
             if(nickpass.indexOf(' ')==-1){
                  infor+="<font color='red'>不能包含空格</font><br/>";
             }else{
             	 infor+="<font color='green'>不能包含空格</font><br/>";
             }
              var flag=false;
           if(nickpass.length<9){
           	
           	for(var i=0;i<nickpass.length;i++){
           		if(nickpass.charAt(i)<'0' || nickpass.charAt(i)>'9'){
           			flag=false;
                   break;
           		}
           	
           	}
           
           }else{
           	flag=true;
           }
           	if(flag==false){
               infor+="<font color='red'>不能是9位以下纯数字</font><br/>";
           	}else{
           		 infor+="<font color='green'>不能是9位以下数字</font>";
           	}
           		document.getElementById("divnickpass").innerHTML=infor;
		}
	</script>
</head>
<body>
	<form action="">
		<table>
			<tr>
				<td>昵称</td>
				<td><input type="text" id="nickname" onblur="checkNickName()" onfocus="alertnickname()"></td>
				<td><div id="divnickname">请输入昵称</div></td>
			</tr>

			<tr>
				<td>密码</td>
				<td><input type="text" id="nickpass" onblur="checkNickPass()" onfocus="alertNickPass()" onkeypress="checkNickPass()"></td>
				<td><div id="divnickpass">请输入密码</div></td>
			</tr>


			<tr>
				<td>生日</td>
				<td>
			        <select id="selYear"></select>
                    <select id="selMonth" onchange="changeDay()"></select>
                    <select id="selDay"></select>
				</td>
				<td><div id="divnickpass">请输入生日</div></td>
			</tr>
		</table>
	</form>
</body>
</html>